<%@page import="at.com.vn.chess.entity.User"%>
<%@page import="at.com.vn.chess.bean.RoomBean"%>
<%@page import="at.com.vn.chess.bean.UserBean"%>
<%@page import="org.apache.log4j.Logger"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%! 
	String rootPath = "";
	final Logger logger = Logger.getLogger( getClass() );
%>
<% 
	rootPath = application.getContextPath();
	logger.info( "Bat dau" );
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>vn shogi - room list</title>
<link href="<%=rootPath %>/pages/styles.css"
	type="text/css" media="screen" rel="stylesheet">
<script type="text/javascript">
	function doSubmit(userID, roomID) {
		document.myform.action = "RoomServlet?UserID=" + userID
				+ "&RoomID=" + roomID;
		document.myform.submit();
	}
	function doLogout(userID) {
		document.myform.action = "RoomServlet?UserID=" + userID;
		document.myform.submit();
	}
</script>
<jsp:useBean id="lstRoomBean" class="at.com.vn.chess.bean.RoomBean"
	scope="request">
</jsp:useBean>
<%
	User currentUser = (User) session
			.getAttribute("currentSessionUser");
%>
</head>
<body id="login" onload="setAppletParams();">


	<div id="wrappertop"></div>
	<div id="wrapper">
		<div id="content">
			<div id="header">
				<h1>
					<a href=""><img
						src="<%=rootPath %>/images/logo.png"
						alt="ChessApplication"> </a>
				</h1>
			</div>
			<div id="darkbanner" class="banner320">
				<h2>Available room</h2>
			</div>
			<div id="darkbannerwrap"></div>

			<form name="myform" method="post">
				<fieldset class="form">
					<p class="message">
						Welcome
						<%=currentUser.getUser_id()%>, please choose room to join
					</p>
					<%
						if (lstRoomBean.getLstRoom() != null
								&& lstRoomBean.getLstRoom().size() > 0) {
							for (int i = 0; i < lstRoomBean.getLstRoom().size(); i++) {
					%>

					<p class="leaf">
						<a
							href="javascript:doSubmit('<%=currentUser.getUser_id()%>','<%=lstRoomBean.getLstRoom().get(i).getRoom_id()%>');">
							<%=lstRoomBean.getLstRoom().get(i).getRoom_name()%> </a>
					</p>

					<%
						}
						}
					%>
				</fieldset>
				<%
					logger.info( "URLBase: " + rootPath );
				%>
				<applet name="CloseBrowser"
					code="at.com.vn.chess.applet.CloseBrowserApplet"
					archive="ChessApplet.jar,XMLHelper.jar,l2fprod-swingx.jar" width=0
					height=0>
					<param name="UserID" value="<%=currentUser.getUser_id()%>">
					<param name="UrlBase" value="<%=rootPath %>" />
					<param name="java_arguments" value="-Dfile.encoding=utf-8">
				</applet>
			</form>
		</div>
	</div>
	<div id="wrapperbottom_branding">
		<div id="wrapperbottom_back_text">
			<a href="javascript:doLogout('<%=currentUser.getUser_id()%>');">Log
				out</a>
		</div>
	</div>
	<jsp:include page="footer_copyright.jsp" />
</body>
</html>